//Myaccount
var members="";
function myAccountForm(){
    var charactervalidation = /^[a-zA-Z\s]*$/;
	var flag=true;
	var userName=$('#inputUser').val();
	var email=$('#inputEmail').val();
	var phone=$('#inputPh').val();
	var Alterphone=$('#alterphone').val();
	var address=$('#txtArea').val();
	var location=$('#location').val();
	var pincode=$('#pincode').val();
	var hid=$('#hid').val();
	if(userName==""){
		$('#userNameError').html(Account_page_user_name);
		flag=false;
	}else if(!userName.match(charactervalidation)){
	    $('#userNameError').html(Account_page_charactervalidation);
		flag=false;
	}else{
		$('#userNameError').html('');
	}
	
	if(email==""){
	   $("#emailError").html(Account_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(email)==0){
		  $("#emailError").html(Account_page_erroremail);
		  flag=false; 
	    }else{
			  $("#emailError").html(""); 
			}
	} 
	if(phone==""){
		$('#phoneNumberError').html(Account_page_phonenumber);
		flag=false;
	}else if(isNaN(phone)){
		  $('#phoneNumberError').html(Account_page_numbervalidation);
		  flag=false;
	}else{
		$('#phoneNumberError').html('');
	}
	
	if(Alterphone==""){
	   $("#erroralterphone").html(Account_page_alterphonenumber);
	   flag=false;   
	}else if(isNaN(Alterphone)){
	   $("#erroralterphone").html(Account_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#erroralterphone").html("");
	}
	
	if(location==""){
		$('#errorLocation').html(Account_page_location );
		flag=false;
	}else{
		$('#errorLocation').html('');
	}
	
	if(address==""){
		$('#addressError').html(Account_page_address);
		flag=false;
	}else{
		$('#addressError').html('');
	}
	
	if(pincode==""){
		$('#errorPincode').html(Account_page_pincode);
		flag=false;
	}else if(isNaN(pincode)){
	   $("#errorPincode").html(Register_page_numbervalidation);
	   flag=false;
	}else{
		$('#errorPincode').html('');
	}
	if(flag==true){
		$('#accountReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'PUT',
			url			:  	webServiceUrl+'registration/'+hid,
			dataType	: 	"json",
			data		:	$('#accountForm1').serialize(),
			success: function(data){
				$('#accountReload').html('');
				if(data.value==1){
					$('updatePhone').html('Ph:&nbsp;'+phone);
					$('updateLocation').html(location);
					sessionStorage.setItem( 'admin_phone', JSON.stringify(phone) );
					sessionStorage.setItem( 'admin_location', JSON.stringify(location) );
					$('#success_alert').show();
					$('#sucessDiv').html(Account_page_success_message);
					$("html, body").animate({ scrollTop: 0 }, 600);
					$('#success_alert').delay(3000).fadeOut('slow');
				}else{
					$('#sucessDiv').html('');
				}
			}
			
		});
	}
}
// Update shop request
function updateShopRequest(user_id){
    var charactervalidation = /^[a-zA-Z\s]*$/;
	var flag=true;
	var userName=$('#inputUser'+user_id).val();
	var email=$('#inputEmail'+user_id).val();
	var phone=$('#inputPh'+user_id).val();
	var alterphone=$('#alterphone'+user_id).val();
	var address=$('#txtArea'+user_id).val();
	var location=$('#location'+user_id).val();
	var pincode=$('#pincode'+user_id).val();
	var status=$('#statusSelect'+user_id).val();
	/*var fax=$('#fax').val();
	var city=$('#city').val();
	var country=$('#country').val();
	var state=$('#state').val();
	*/
	if(userName==""){
		$('#userNameError').html(Account_page_user_name);
		flag=false;
	}else if(!userName.match(charactervalidation)){
	    $('#userNameError').html(Account_page_charactervalidation);
		flag=false;
	}else{
		$('#userNameError').html('');
	}
	
	if(email==""){
	   $("#emailError").html(Account_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(email)==0){
		  $("#emailError").html(Account_page_erroremail);
		  flag=false; 
	    }else{
			  $("#emailError").html(""); 
			}
	} 
	if(phone==""){
		$('#phoneNumberError').html(Account_page_phonenumber);
		flag=false;
	}else if(isNaN(phone)){
		  $('#phoneNumberError').html(Account_page_numbervalidation);
		  flag=false;
	}else{
		$('#phoneNumberError').html('');
	}
	if(alterphone==""){
		$('#alterphoneNumberError').html(Account_page_phonenumber);
		flag=false;
	}else if(isNaN(phone)){
		  $('#alterphoneNumberError').html(Account_page_numbervalidation);
		  flag=false;
	}else{
		$('#alterphoneNumberError').html('');
	}
	if(location==""){
		$('#errorLocation').html(Account_page_location );
		flag=false;
	}else{
		$('#errorLocation').html('');
	}
	
	if(address==""){
		$('#addressError').html(Account_page_address);
		flag=false;
	}else{
		$('#addressError').html('');
	}
	
	if(pincode==""){
		$('#errorPincode').html(Account_page_pincode);
		flag=false;
	}else if(isNaN(pincode)){
	   $("#errorPincode").html(Account_page_numbervalidation);
	   flag=false;
	}else{
		$('#errorPincode').html('');
	}
	if(status==""){
		 $("#errorstate").html(Account_page_status);
			flag=false;
	}else{
	   $("#errorstate").html("");
	   
	}

	if(flag==true){
		$('#accountReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'PUT',
			url			:  	webServiceUrl+'registration/'+user_id,
			dataType	: 	"json",
			data		:	{inputUser:userName,status:status,txtArea:address,pincode:pincode,inputPh:phone,location:location,alterphone:alterphone},
			success: function(data){
				$('#accountReload').html('');
				if(data.value==1){
					$('#success_alert').show();
					$('#sucessDiv'+user_id).show();
					$('#sucessDiv'+user_id).html(Account_page_success_message).delay(3000).fadeOut('slow');;
					$('#cancelled_order').html(Account_page_success_message);
					$("html, body").animate({ scrollTop: 0 }, 600);
					$('#success_alert').delay(3000).fadeOut('slow');
					if(status==0){
						$('#status'+user_id).html('Blocked');
					}else if(status==1){
						$('#status'+user_id).html('Active');
					}else{
						$('#status'+user_id).html('Pending');
					}
				}
			}
			
		});
	}
}
//login Form validations
function loginForm(){
	var flag=true;
	var userName=$('#username').val();
	var password=$('#password').val();
	if(userName==""){
	   $("#usernameError").html(Login_user_email);
	   flag=false;   
	}else{
	    if(validateEmail(userName)==0){
		  $("#usernameError").html(Login_user_erroremail);
		  flag=false; 
	    }else{
			  $("#usernameError").html(""); 
		}
	}
	
	if(password==""){
		$('#pwdError').html(Login_user_password);
		flag=false;
	}else{
		$('#pwdError').html('');
	}
	
	if(flag==false){
		return false;
	}else{
	$('#reload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'login',
			dataType	: 	"json",
			data		:	{
								email:userName,pwd:password,user_type_id:'1'
							},
			success: function(data){
				$('#reload').html('');
				 if(data.status=="success"){
					var obj = eval("(" + data.UserDetails + ")");
					$.each(obj, function (index,Object) {
						var user_id		=	Object.user_id;
						var email		=	Object.email;
						var phone		=	'9888888888';
						var location	=	'Hyderabad';
						sessionStorage.setItem( 'admin_user_id', JSON.stringify(user_id) );		
						sessionStorage.setItem( 'admin_email', JSON.stringify(email) );
						sessionStorage.setItem( 'admin_phone', JSON.stringify(phone));
						sessionStorage.setItem( 'admin_location', JSON.stringify(location));
					});
					window.location="account.html";
				}else{
					$('#logsucess').html(Login_error_message);
				}
			}
		});
	}
}
//Forget Password Form validations
function forgetForm(){
    var flag=true;
	var email=$('#inputuser').val();
	
	if(email==""){
	   $("#forgetMailError").html(Forgotpassword_email);
	   flag=false;   
	}else{
	    if(validateEmail(email)==0){
		  $("#forgetMailError").html(Forgotpassword_error_email);
		  flag=false; 
	    }else{
			  $("#forgetMailError").html(""); 
			}
	}
	
	if(flag==false){
		return false;
	}else{
	   $('#forgetReload').html('<img src="images/ajax-loader.gif"/>');
	   $.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'forgetpassword',
			dataType	: 	"json",
			data		:	{
								email:email,type:1
							},
			success: function(data){
			$('#forgetReload').html('');
				if(data.value==1){
					$('#successfpassword').html(Forgotpassword_success_message);
				}else{
					$('#successfpassword').html(Forgotpassword_error_message);
				}
			}
		});
	}
}
//Registration Form Validation

function userRegister(){
emailValidation();
var flag=true;
var charactervalidation = /^[a-zA-Z\s]*$/;
var Firstname=$("#inputFirstname").val();
var Email=$("#inputEmail").val();
var Telephone=$("#inputTelephone").val();
var Alterphone=$('#alterphone').val();
var Landmark=$('#landmark').val();
var Location=$("#location").val();
var Address=$("#inputAddress").val();
var Pincode=$("#pincode").val();
var Password=$("#password").val();
var Conformpassword=$("#ConformPassword").val();
   
	if(Firstname==""){
	   $("#errorFirstname").html(Register_page_firstname);
	   flag=false;   
	}else if(!Firstname.match(charactervalidation)){
	   $("#errorFirstname").html(Register_page_charactervalidation);
	   flag=false;
	}else{
	  $("#errorFirstname").html("");
	}
	
	if(Email==""){
	   $("#errorEmail").html(Register_page_email);
	   flag=false;   
	}else{
	    if(validateEmail(Email)==0){
		  $("#errorEmail").html(Register_page_erroremail);
		  flag=false; 
	    }
		else if($('#hidemailerror').val()=='1'){
			$('#errorEmail').html(Register_page_checkerroremail);
			flag=false;
		}else{
			  $("#errorEmail").html(""); 
			}
	}
	
	if(Telephone==""){
	   $("#errorTelephonenumber").html(Register_page_phonenumber);
	   flag=false;   
	}else if(isNaN(Telephone)){
	   $("#errorTelephonenumber").html(Register_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#errorTelephonenumber").html("");
	}
	
	if(Alterphone==""){
	   $("#erroralterphone").html(Account_page_alterphonenumber);
	   flag=false;   
	}else if(isNaN(Alterphone)){
	   $("#erroralterphone").html(Account_page_numbervalidation);
	   flag=false;   
	}else{
	  $("#erroralterphone").html("");
	}
	
	if(Landmark==""){
	   $("#errorlandmark").html(Register_page_Landmark);
	   flag=false;   
	}else{
	  $("#errorlandmark").html("");
	} 

	if(Location==""){
	   $("#errorlocation").html(Register_page_location);
	   flag=false;   
	}else{
	  $("#errorlocation").html("");
	}
	
	if(Address==""){
	   $("#errorAddress").html(Register_page_address);
	   flag=false;   
	}else{
	  $("#errorAddress").html("");
	}
	
	if(Pincode==""){
	   $("#errorpincode").html(Register_page_pincode);
	   flag=false;   
	}else if(isNaN(Pincode)){
	   $("#errorpincode").html(Register_page_numbervalidation);
	   flag=false;
	}else{
	  $("#errorpincode").html("");
	}
	if(Password==""){
	   $("#errorpassword").html(Register_page_password);
	   flag=false;   
	}else{
	  $("#errorpassword").html("");
	}
	if(Conformpassword==""){
	   $("#errorCPassword").html(Register_page_confirmpassword);
	   flag=false;   
	}else if(Password!=Conformpassword){
	   $("#errorCPassword").html(Register_page_errorconfirmpassword);
	   flag=false;
	}else{
	  $("#errorCPassword").html("");
	}
	if(flag==false){
		  return false;
		}else{
			/*if($('input[name=optionsRadios]:checked').val()==1){
				$.ajax({
					type		:	'POST',
					url			:  	webServiceUrl+'subscriber',
					dataType	: 	"json",
					data		:	{email:Email},
					success: function(data){
						if(data.value==1){
							$('#successSubcription').html('Your successfully subscribed');
						}else{
							$('#successSubcription').html('Your already subscribed user');
						}
					}
				});
			}*/
			$('#registerReload').html('<img src="images/ajax-loader.gif"/>');
			$.ajax({
				type		:	'POST',
				url			:  	webServiceUrl+'registration',
				dataType	: 	"json",
				data		:	$('#Registration').serialize(),
				success: function(data){
					$('#registerReload').html('');
					if(data.value==1){
						var user_id		=	data.UserId;
						var email		=	Email;
					//	sessionStorage.setItem( 'admin_user_id', JSON.stringify(user_id) );	
					//	sessionStorage.setItem( 'admin_email', JSON.stringify(email) );	
						window.location="all-shops.html";
					}
				}
			});
		}
	
}
//Email validation server side
function emailValidation(){
	var emailcheck=$('#inputEmail').val();
	if(emailcheck!==''){
		if(validateEmail(emailcheck)=='0')
		{
			$('#errorEmail').html(sever_error_email);		
		}else{	
			$.ajax({
				type		:	'GET',
				url			:  	webServiceUrl+'login/'+emailcheck,
				dataType	: 	"json",
				success: function(data){
					if(data.value==1){
						$('#hidemailerror').val('1');
						$('#errorEmail').html(server_check_email);
						return 1;
					}else{
						$('#hidemailerror').val('0');
						$('#errorEmail').html("");
						return 0;
					}
				}
			});
		}
  }
}

// Change Password
function changePassword(){
   var flag=true;
   var Oldpassword=$("#oldpassword").val();
   var Newpassword=$("#newPassword").val();
   var Confirmpassword=$("#Confirmpassword").val();
	if(Oldpassword==""){
      $("#errorOldpassword").html(Change_old_password);
	  flag=false;
	}else{
      $("#errorOldpassword").html("");
	}
	
	if(Newpassword==""){
      $("#errorNewpassword").html(Change_new_password);
	  flag=false;
	}else{
      $("#errorNewpassword").html("");
	}
	
	if(Confirmpassword==""){
        $("#errorConfirmpassword").html(Change_confirm_password);
		flag=false;
	}else if(Newpassword!=Confirmpassword){
	   $("#errorConfirmpassword").html(Change_errorconfirm_password);
	   flag=false;
	}else{
       $("#errorConfirmpassword").html("");
	}
	
	if(flag==true){
		$('#changePasswordReload').html('<img src="images/ajax-loader.gif"/>');
		var user_id = JSON.parse(sessionStorage["admin_user_id"]);
        $.ajax({
				type		:	'PUT',
				url			:  	webServiceUrl+'changepassword/'+user_id,
				dataType	: 	"json",
				data        : {old_password:Oldpassword,cnf_password:Confirmpassword},
				success: function(data){
					$('#changePasswordReload').html('');
					if(data.value==1){
						$('#success_alert').show();
						$('#errorCpassword').html(Change_successpassword_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
						$("#oldpassword").val('');
					    $("#newPassword").val('');
						$("#Confirmpassword").val('');
					}else{
						$('#error_alert').show();
						$('#errorCpasswordError').html(Changepassword_error_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						//$('#error_alert').delay(3000).fadeOut('slow');
					}
				}
		});
	}
}

//Reset password
function passwordReset(){
  var flag=true;
  var Resetpassword=$("#resetPassword").val();
  var Confirmpassword=$("#Confirmpassword").val();
    if(Resetpassword==""){
      $("#errorResetpassword").html(Reset_newpassword);
	  flag=false;
	}else{
      $("#errorResetpassword").html("");
	}
	
	if(Confirmpassword==""){
        $("#errorConfirmpassword").html(Reset_confirm_password);
		flag=false;
	}else if(Resetpassword!=Confirmpassword){
	   $("#errorConfirmpassword").html(Resetpassword_confirm_errormessage);
	   flag=false;
	}else{
       $("#errorConfirmpassword").html("");
	}
	
	if(flag==false){
	   return false;
	}else{
	   var path = window.location.href;
	   path = path.replace(/\/$/, "");
	   path = decodeURIComponent(path);
       var id=path.split('=');
       var token=id[1];
	   $('#resetPasswordReload').html('<img src="images/ajax-loader.gif"/>');
	    $.ajax({
				type		:	'PUT',
				url			:  	webServiceUrl+'forgetpassword/'+token,
				dataType	: 	"json",
				data        : {cnf_password:Confirmpassword},
				success: function(data){
					$('#resetPasswordReload').html('');
					if(data.value==1){
						$('#success_alert').show();
						$('#errorSuccess').html(Resetpassword_success_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else{
						$('#errorSuccessError').html(Resetpassword_error_message);
					}
				}
		});
	}
}
function logoutFunction(){
	sessionStorage.removeItem("admin_user_id");
	sessionStorage.removeItem("admin_email");
	sessionStorage.removeItem("admin_user_type");
	window.location="index.html";
}
/*function subscribe(){
	var Email=$('#subscribe').val();
	if(Email!=""){
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'subscriber',
			dataType	: 	"json",
			data		:	{email:Email},
			success: function(data){
				if(data.value==1){
					$('#footerSubcription').html('Your successfully subscribed');
				}else{
					$('#footerSubcription').html('Your already subscribed user');
				}
			}
		});
	}else{
		$('#footerSubcription').html('Please enter email');
	}
}*/


//get state values list

function getstateValues(){

  var country=$("#country").val();
   $.ajax({
				type		:	'POST',
				url			:  	webServiceUrl+'state',
				dataType	: 	"json",
				data        : {countryId:country},
				success: function(data){
					var statedetailes;
					if(data.value==0){
						statedetailes +='<option value="">Select state</option>';
					}else{
					    var obj = eval("(" + data.data + ")");
						if(typeof sessionStorage["admin_user_id"]=='undefined'){
							
							$.each(obj, function (index,Object) {
								statedetailes +='<option  value="'+Object.state_id+'">'+Object.state_name+'</option>';
							});
						}else{
						  $.each(obj, function (index,Object) {
						             var user_state=$("#hidstate").val();
									if(user_state==Object.state_id){
									   statedetailes +='<option  selected value="'+Object.state_id+'">'+Object.state_name+'</option>';
									}else{
									   statedetailes +='<option  value="'+Object.state_id+'">'+Object.state_name+'</option>';
									}
								});
						}
					}
					$('#state').html(statedetailes);
				}
		});
}
// Admin Shop table 

function changeStatus(status,user_id,user_type_id)
{
	var Ctype="";
	if(status==0){
		Ctype="Block";
	}else{
		Ctype="Active";
	}
	$.ajax({
		type		:	'PUT',
		url			:  	 webServiceUrl+'admin-delete-user/'+user_id,
		data 		: {status:status,compliantType:Ctype,user_type_id:user_type_id,tracking_id:'0',complaint_id:'0'},
		dataType	: 	"json",
		success: function(data){
		if(data.output=="success")
		{
			if(status=='0')
			{
				$('#status'+user_id).html('Blocked');
				$('#userpopup'+user_id).html('Blocked');
				$('#user'+user_id).html('<a href="javascript:void(0);" onclick="changeStatus(1,'+user_id+','+user_type_id+')">Active</a>'+'/'+'<a href="#view'+user_id+'" role="button" class="" data-toggle="modal">View</a>');
			}
			 else{
				$('#status'+user_id).html('Active');
				$('#userpopup'+user_id).html('Active');
				$('#user'+user_id).html('<a  href="javascript:void(0);" onclick="changeStatus(0,'+user_id+',,'+user_type_id+')">Block</a>'+'/'+'<a href="#view'+user_id+'" role="button" class="" data-toggle="modal">View</a>');
			 }
		}
		}
	});
}

//Confirm shop popUp
function sentQuotationPopUp(tracking_id){
	var location=$('#location'+tracking_id).val();
	var htmlPopup="";
	$.ajax({
		type		:	'GET',
		url			:  	webServiceUrl+'confirm-shop-pop-up/'+tracking_id,
		dataType	: 	"json",
		success: function(data){
			if(data.value==1){
				htmlPopup+='<div id="confirm'+tracking_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Confirm Shop</h3></div><div id="popup" class="modal-body">';
				htmlPopup+='<form id="confirmForm"><p><b>Tracking Id:'+tracking_id+'</b>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green" id="successConfirm"><span></p>';
				htmlPopup+='<table class="table table-bordered">'+
							'<tr class="table_th_bg">'+
							'<th>Time</th>'+
							'<th>Shop Name</th>'+
							'<th>Price</th>'+
							'<th>Contact Number</th>'+
							'<th>Alternative Number</th>'+
							'<th>Action</th>'+
						'</tr>';
				var obj = eval("(" + data.orders + ")");
				var deletIds="";
				$.each(obj, function (index,Object) {
					htmlPopup+=	'<tr>'+
					'<td>'+Object.date_updated+'</td>'+
					'<td>'+Object.user_name+'</td>';
					if(Object.price!=null){
						htmlPopup+=	'<td>'+Object.price+'</td>';
					}else{
						htmlPopup+=	'<td>Not sent</td>';
					}
					htmlPopup+=	'<td>'+Object.phone+'</td>'+
					'<td>'+Object.alterphone+'</td>';
					if(Object.price!=null){
						if(Object.shop_order_status==2){
							htmlPopup+=	'<td id="confirmm'+Object.order_delivery_details_id+'"><b style="color:red">Confirmed</b></td>';
						}else if(Object.shop_order_status==3){
							htmlPopup+=	'<td id="confirmm'+Object.order_delivery_details_id+'"><a href="javascript:void(0);" onclick="confirmOrder('+Object.order_delivery_details_id+','+tracking_id+')"><b style="color:green">Confirm</b></a></td>';
						}else if(Object.shop_order_status==1){
							htmlPopup+=	'<td id="confirmm'+Object.order_delivery_details_id+'"><a href="javascript:void(0);" onclick="confirmOrder('+Object.order_delivery_details_id+','+tracking_id+')"><b style="color:green">Confirm</b></a></td>';
						}else if(Object.shop_order_status==0){
							htmlPopup+=	'<td id="confirmm'+Object.order_delivery_details_id+'"><a href="javascript:void(0);" onclick="confirmOrder('+Object.order_delivery_details_id+')"><b style="color:green">Confirm</b></a></td>';
						}
					}else{
						htmlPopup+=	'<td id="confirmm'+Object.order_delivery_details_id+'">Not Sent</td>';
					}
				'</tr>';
						deletIds+=Object.order_delivery_details_id+'***';
				});
				htmlPopup+='<input type="hidden" id="deleteIds" name="deleteIds" value="'+deletIds+'"/>';
				htmlPopup+='</table></form>'+
					'<span id="sendsuccess" style="color:green"></span>';
				htmlPopup+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
				$('#confirm_quotation_popup').html(htmlPopup);
				$('#confirm'+tracking_id).modal('show');
			}
		}
	});
}
//Confirm shop
function confirmOrder(oddId,trackingId){
	var admin_id = JSON.parse(sessionStorage["admin_user_id"]);
	var delOrderIds=$('#deleteIds').val().slice(0,-3);
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'order-quotations-from-shops/1',
		dataType	: 	"json",
		data		:	{admin_confirm:1,status:1,confirmOrderId:oddId,deleteOrderids:delOrderIds,admin_id:admin_id,complaintType:"Confirmed",trackingId:trackingId},
		success: function(data){
			if(data.value==1){
				$('#successConfirm').html('Confirm Shop Success');
				var ids=delOrderIds.split('***');
				for(var i=0;i<=(ids.length)-1;i++){
					if(ids[i]!=oddId){
						$('#confirmm'+ids[i]).html('<b style="color:red">Canceled</b>');
					}else{
						$('#confirmm'+ids[i]).html('<b style="color:green">Confirm</b>');
					}
				}
			}
		}
	});
}
//Send Quotation to shops pop up
function sendQuotationPopUp(pincode,tracking_id){
	var location=$('#location'+tracking_id).val();
	var htmlPopup="";
	$.ajax({
		type		:	'POST',
		url			:  	webServiceUrl+'admin-all-shops',
		dataType	: 	"json",
		data		:	{pincode:pincode,location:location,type_id:3,status:1},
		success: function(data){
			if(data.value==1){
				htmlPopup+='<div id="quotation'+tracking_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Send Quotation</h3></div><div id="popup" class="modal-body">';
				htmlPopup+='<form id="discounttForm"><p>Tracking Id:'+tracking_id+'</p>';
				htmlPopup+='<table><tr>'+
				'<td>Location:</td><td>'+location+'</td>'+
				'<td>Pincode:</td><td>'+pincode+'</td>'+
				'</tr></table>';
				htmlPopup+='<table class="table table-bordered">'+
							'<tr class="table_th_bg">'+
							'<th><input type="checkbox" id="allCheck" name="allCheck" onclick="selectAllCheck()">SelectAll</th>'+
							'<th>Shop Name</th>'+
							'<th>Contact Number</th>'+
							'<th>Alternative Number</th>'+
						'</tr>';
						
				var obj = eval("(" + data.result + ")");
				$.each(obj, function (index,Object) {
					htmlPopup+=	'<tr>'+
								'<td><input type="checkbox" class="Check1" name="Check[]" onclick="uncheckSelectAll()" value="'+Object.user_id+'"></td>'+
								'<td>'+Object.user_name+'</td>'+
								'<td>'+Object.phone+'</td>'+
								'<td>'+Object.alterphone+'</td>'+
							'</tr>';
				});
				htmlPopup+='</table>'+
				'<div class="control-group">'+
					'<label class="control-label" for="inputAd">Discount</label>'+
					'<div class="controls">'+
						'<input type="radio" id="discountt1" name="discountt" onclick="discountSelect(1)"> Yes &nbsp;&nbsp;'+
						'<input type="radio" id="discountt0" name="discountt" onclick="discountSelect(0)" checked> No'+
					'</div>'+
				'</div>'+
				'<div class="control-group" style="display:none" id="PriceRadio">'+
						'<label class="control-label" for="inputPh">Price</label>'+
						'<div class="controls">'+
						'<input type="text" class="span4" id="Price" name="Price">'+
						'<span id="PriceError" style="color:red"></span>'+
						'</div>'+
					'</div><p><a href="javascript:void(0);" onclick="sendQuotationToShops('+tracking_id+');">Send</a></p></form>'+
					'<span id="checkboxError" style="color:red"></span>'+
					'<span id="sendsuccess" style="color:green"></span>'+
					'<input type="hidden" id="hidDiscountValue" name="hidDiscountValue" value="0"/>';
				htmlPopup+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
				console.log(htmlPopup);
				$('#send_quotation_popup').html(htmlPopup);
				$('#quotation'+tracking_id).modal('show');
			}
		}
	});
}
//Send Quotation to shops
function sendQuotationToShops(tracking_id){
	 var admin_id = JSON.parse(sessionStorage["admin_user_id"]);
	$('#sendsuccess').html('');
	var flag=true;
	var selectedShops="";
	var checkboxes=document.getElementsByTagName("INPUT");	
	var len=checkboxes.length;	
	var cnt = 0;
	for(var i=0;i<len;i++)
	{		
		if(checkboxes[i].name=="Check[]")
		{		
			if(checkboxes[i].checked)
			{
				selectedShops+=checkboxes[i].value+'***';
				cnt++;
			}
		}
	}
	if(cnt == 0) 
	{
		$('#checkboxError').html(Select_shops_send_quotation);
		flag=false;
	}else{
		$('#checkboxError').html('');
	}
	if($('#hidDiscountValue').val()==1){
		if($('#Price').val()==""){
		    $('#PriceError').html(send_price);
			flag=false;
		}else if(isNaN($('#Price').val())){
			$("#PriceError").html(send_numbers_message);
			flag=false;
		}else{
			var discount=$('#Price').val();
			 $('#PriceError').html('');
		}
	}else{
		$('#Price').val("");
		var discount=$('#Price').val();
	}
	if(flag==true){
		var shops=selectedShops.slice(0,-3);
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'send-notification-to-shops',
			dataType	: 	"json",
			data		:	{shop_ids:shops,user_medicine_order_id:tracking_id,discount:discount,compliantType:"sendQuotation",user_id:"0",complaint_id:"0",tracking_id:tracking_id},
			success: function(data){
				if(data.value==1){
					$('#sendsuccess').html(Quotation_sent_successfully_message);
					$('#status'+tracking_id).html(Quotation_send);
					$('#SendQuotation'+tracking_id).html(Resend_quotation);
				}
			}
		});
	}	
}
//CancelOrder in order history
function cancelOrder(tracking_id){
    var Cancelledorder_tracking_id=tracking_id;
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'order/'+Cancelledorder_tracking_id,
		dataType	: 	"json",
		data		:	{compliantType:"Cancelled",complaint_id:"0",tracking_id:Cancelledorder_tracking_id},
		success: function(data){
			if(data.value==1){
				$('#status'+tracking_id).html('Cancelled');
				$('#action'+tracking_id).html('<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');
			}
		}
	});
}
   
// Order online page
function sendOrder(){
	var vvalue=0;
	var value=0;
	var flag=true;
	$('input[name="tabletName[]"]').each(function() {
		if ($.trim(this.value) == '') {
			value=1;
			flag=false;
		}
	});
	$('input[type="number"]').each(function() {
		if ($.trim(this.value) == '') {
			vvalue=3;
			flag=false;
		}else if($.trim(this.value) <=0){
			vvalue=2;
			flag=false;
		}
	});
	if(value==1){
		$('#textboxes').html(Order_page_manualfields);
	}else{
		$('#textboxes').html('');
	}
	if(vvalue==2 || vvalue==3){
		$('#textboxess').html(Order_page_integervalidation);
	}else{
		$('#textboxess').html('');
	}
	if(!$('#autoRenewal').is(':checked')){
		if(typeof $('input[name=autoRenewal]:checked', '#orderForm').val()=="undefined"){
			$('#autoRenewalError').html(Order_page_autorenewal);
			flag=false;
		}else{
			$('#autoRenewalError').html('');
		}
	}else{
		$('#autoRenewalError').html('');
	}
	if($('input[name=autoRenewal]:checked', '#orderForm').val()==1){
		if($('#eachDays').val()==""){
			$('#eachDaysError').html(Order_page_days);
			flag=false;
		}else{
			$('#eachDaysError').html('');
		}
	}
	if(flag==true){
		$('#orderOnlineReload').html('<img src="images/ajax-loader.gif"/>');
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'order',
			dataType	: 	"json",
			data		:	$('#orderForm').serialize(),
			success: function(data){
				$('#orderOnlineReload').html('');
				if(data.value==1){
					window.location="user-acknowledgement.html?TID="+data.TrackingId;
				}
			}
		});
	}
}
function removediv(){
  $("#removediv").remove();
}
function removediv1(){
  $("#removediv1").remove();
}
//End

//Reviews and ratings
function validateReviews(){
    var flag=true;
	var trackId=$("#reviewTrackId").val();
	var ratingValue=$("#hidRating").val();
	var reviewText=$("#textArea").val();
	if(trackId==""){
	   $("#errorReviewTrackId").html(Track_id);
	   flag=false;   
	}else if(isNaN(trackId)){
	   $("#errorReviewTrackId").html(Tracking_id_number);
	   flag=false;   
	}else{
	  $("#errorReviewTrackId").html("");
	}
	if(reviewText==""){
		$("#reviewError").html(Review);
		flag=false;
	}else{
		$("#reviewError").html("");
	}
	if(ratingValue==0){
		$("#ratingError").html(Review_rating);
		flag=false;
	}else{
		$("#ratingError").html("");
	}
	if(flag==false){
	   return false;
	}else{
		$('#userReviewReload').html('<img src="images/ajax-loader.gif"/>');
	   var user_id = JSON.parse(sessionStorage["admin_user_id"]);
	   $.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'reviews',
			dataType	: 	"json",
			data		:	{user_id:user_id,trackingID:trackId,rating:ratingValue,review:reviewText},
			success: function(data){
				$('#userReviewReload').html('');
				if(data.value==1){
				   // var textarea=0;
				        $("#reviewTrackId").val('');
						$("#hidRating").val('0');
						$("#textArea").val('');
						$('#success_alert').show();
						$("#Checktracking_id").html(Review_rating_success_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
				}else{
						$('#error_alert').show();
						$("#Checktracking_idError").html(Review_rating_validtracking_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
				}
			}
		});	
	}
}
function ratingOrder(value){
	var html="";
	for(var i=1;i<=value;i++){
		html+='<a href="javascript:void(0)" onclick="ratingOrder('+i+')"><img class="star" src="images/green-star.png"></a>';
	}for(var i=value+1;i<=5;i++){
		html+='<a href="javascript:void(0)" onclick="ratingOrder('+i+')"><img class="star" src="images/gray-star.png"></a>';
	}
	$('#rating').html(html);
	$('#hidRating').val(value);
}
//  Admin order status
function Findorderstatus(){
 var flag=true;
	var orderTrackId=$("#orderTrackId").val();
	if(orderTrackId==""){
	   $("#errorOrderTrackId").html(Orderstatustrack_id);
	   flag=false;   
	}else if(isNaN(orderTrackId)){
	   $("#errorOrderTrackId").html(Orderstatustracking_id_number);
	   flag=false;   
	}else{
	  $("#errorOrderTrackId").html("");
	}
	if(flag==true){
		$('#orderStatusReload').html('<img src="images/ajax-loader.gif"/>');
	    var user_id = JSON.parse(sessionStorage["admin_user_id"]);
		   $.ajax({
				type		:	'GET',
				url			:  	webServiceUrl+'order-status/order_status-'+orderTrackId,
				dataType	: 	"json",
				success: function(data){
					$('#orderStatusReload').html('');
					$("#orderTrackId").val("");
					if(data.value==0){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_pending);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else if(data.value==1){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_processing);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else if(data.value==2){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_processed);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else if(data.value==3){
						$('#success_alert').show();
						$("#orderStatusId").html(Orderstatus_cancelled);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
						$('#error_alert').hide();
					}else{
						$('#error_alert').show();
						 $("#orderStatusIdError").html(Orderstatus_error_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
					}
				}
			});
	}
}

//View all discounts/


//change paid status 

function paidDiscount(tracking_id){
	 var admin_id = JSON.parse(sessionStorage["admin_user_id"]);
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'discounts/'+tracking_id,
		dataType	: 	"json",
		data		:{tracking_id:tracking_id,compliantType:"Discount",complaint_id:"0",admin_id:admin_id}, 	
		success: function(data){
			if(data.value==1){
				$("#status"+tracking_id).html('Paid');
				$("#action"+tracking_id).html('Completed');
			}
		}
	});
}

//User complaints 
function validUserComplaint(){
    var flag=true;
	var complaintTrackId=$("#complaintId").val();
	var userComplaint=$("#textArea").val();
	
	if(complaintTrackId==""){
	   $("#errorComplaintTrackId").html(Complaint_track_id);
	   flag=false;   
	}else if(isNaN(complaintTrackId)){
	   $("#errorComplaintTrackId").html(Complaint_track_id_number);
	   flag=false;   
	}else{
	  $("#errorComplaintTrackId").html("");
	}
	
	if(userComplaint==""){
		$("#complaintError").html(Complaint);
		flag=false;
	}else{
		$("#complaintError").html("");
	}
	if(flag==false){
	   return false;
	}else{
	    $('#userComplaintReload').html('<img src="images/ajax-loader.gif"/>');
	    var user_id = JSON.parse(sessionStorage["admin_user_id"]);
		$.ajax({
			type		:	'POST',
			url			:  	webServiceUrl+'complaints',
			dataType	: 	"json",
			data		:	{user_id:user_id,complaint:userComplaint,tracking_id:complaintTrackId},
			success: function(data){
				$('#userComplaintReload').html('');
				if(data.value==1){
				        $("#complaintId").val("");
	                    $("#textArea").val("");
						$('#success_alert').show();
						$("#CheckComplaint").html(Complaint_success_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
						$('#success_alert').delay(3000).fadeOut('slow');
				}else{
						$('#error_alert').show();
						$("#CheckComplaintError").html(Complaint_validtracking_message);
						$("html, body").animate({ scrollTop: 0 }, 600);
				}
			}
		});
	
	}
}

//Renewal order

 //Send order to new orders
 function sendOrderToNewOrders(user_id,oldorderId){
	$.ajax({
		type		:	'POST',
		url			:  	webServiceUrl+'order',
		dataType	: 	"json",
		data		:	{user_id:user_id,oldorderId:oldorderId},
		success: function(data){
			if(data.value==1){
				$('#sendorderre'+oldorderId).html('Send success');
			}
		}
	});
 }
 //cancelled order
function cancelautorenewalFun(tracking_id,autorenuval){
 var admin_id = JSON.parse(sessionStorage["admin_user_id"]);
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'disable-order-renewal/'+tracking_id,
		dataType	: 	"json",
		data		:	{auto_renewal:autorenuval,adminId:admin_id},
		success: function(data){
			if(data.value==1){
				if(autorenuval==0){
					$('#auto'+tracking_id).html('No');
					var text='Enable autorenewal';
					$('#cancelautorenewal'+tracking_id).html('<a href="javascript:void(0)" onclick="cancelOrder('+tracking_id+')">Cancel</a>'+'/'+'<a href="javascript:void(0)" onclick="cancelautorenewalFun('+tracking_id+',1)">'+text+'</a>'+'/'+'<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');
				}else{
					$('#auto'+tracking_id).html('Yes');
					var text='Cancel autorenewal';
					$('#cancelautorenewal'+tracking_id).html('<a href="javascript:void(0)" onclick="cancelOrder('+tracking_id+')">Cancel</a>'+'/'+'<a href="javascript:void(0)" onclick="cancelautorenewalFun('+tracking_id+',0)">'+text+'</a>'+'/'+'<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');
				}
				/*$('#cancelautorenewal'+tracking_id).html('<a href="javascript:void(0)" onclick="cancelOrder('+tracking_id+')">Cancel</a>'+'/'+'<a href="javascript:void(0)" onclick="cancelautorenewalFun('+tracking_id+',1)">'+text+'</a>'+'/'+'<a href="#'+tracking_id+'" role="button" class="" data-toggle="modal">View</a>');*/
			}
		}
	});
}
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}


//Customer Review list




//recent work  



function pageselectCallbackAdminallshops(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var count=0;
	var html="";
	var auto_renewal='';
	var each_days='';
	var status='';
	var prescription_upload_path='';
	var delivered_date='';
	var action='';
	var viewDetailes='';
	var Editshopdetailes='';
	html+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Date Added</th>'+
				'<th>Shop Name</th>'+
				'<th>Email</th>'+
				'<th>Phone</th>'+
				'<th>Status</th>'+
				'<th>Action</th>'+
			'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
		if(pagei<max_elem){
			var user_name=Object.user_name;
			var email=Object.email;
			var date_added=Object.date_added;
			var date_updated=Object.date_updated;
			var landmark=Object.landmark;
			var address=Object.address;
			var phone=Object.phone;
			var alterphone=Object.alterphone;
			var location=Object.location;
			var pincode=Object.pincode;
			var phone=Object.phone;
			var fax=Object.fax;
			if(Object.status=='1')
			{
				var status='Active';
				var action='<a href="javascript:void(0)" onclick="changeStatus(0,'+Object.user_id+','+Object.user_type_id+')">Block</a>'+'/'+'<a href="#view'+Object.user_id+'" role="button" class="" data-toggle="modal">View</a>';
				
			}else if(Object.status=='0'){
				var status='Blocked';
				var action='<a href="javascript:void(0)" onclick="changeStatus(1,'+Object.user_id+','+Object.user_type_id+')">Active</a>'+'/'+'<a href="#view'+Object.user_id+'" role="button" class="" data-toggle="modal">View</a>';
				
			}else{
				var status='Pending';
				var action='<a href="#editview'+Object.user_id+'" "role="button" class="" data-toggle="modal">View</a>';
				
			}
				viewDetailes+='<div id="view'+Object.user_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Order Detailes</h3></div><div id="popup" class="modal-body">'+
						'<table class="table table-condensed">'+
							'<tr><th>ShopName</th><td>'+user_name+'</td></tr>'+
							'<tr><th>Email</th><td>'+email+'</td></tr>'+
							'<tr><th>Landmark</th><td>'+landmark+'</td></tr>'+
							'<tr><th>Address</th><td>'+address+'</td></tr>'+
							'<tr><th>Phonenumber</th><td>'+phone+'</td></tr>'+
							'<tr><th>AlterPhonenumber</th><td>'+alterphone+'</td></tr>'+
							'<tr><th>Location</th><td>'+location+'</td></tr>'+
							'<tr><th>pincode</th><td>'+pincode+'</td></tr>'+
							'<tr><th>Status</th><td  id="userpopup'+Object.user_id+'">'+status+'</td></tr>'+
						'</table>'+	
					'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
				
				Editshopdetailes+='<div id="editview'+Object.user_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Order Detailes</h3></div><div id="popup" class="modal-body">'+
						'<form class="form-horizontal mar_top" id="Registration" name="Registration">'+
						'<div class="control-group">'+
							'<label class="control-label" for="inputUser">Shop Name</label>'+
							'<div class="controls">'+
							'<input type="text" class="span8" id="inputUser'+Object.user_id+'" name="inputUser'+Object.user_id+'" value="'+user_name+'" placeholder="Please Enter Shop Name ">'+
							'<span id="errorFirstname" name="errorFirstname" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<label class="control-label" for="inputEmail">Email ID</label>'+
							'<div class="controls">'+
							'<input type="text" class="span8" id="inputEmail'+Object.user_id+'" name="inputEmail'+Object.user_id+'" placeholder="Please Enter Email ID" value="'+email+'" readonly>'+
							'<span id="errorEmail" name="errorEmail" style="color:red"></span>'+
							'<span id="errorEmail1" name="errorEmail1" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<label class="control-label" for="inputPh">PhoneNumber</label>'+
							'<div class="controls">'+
							'<input type="text" class="span8" id="inputPh'+Object.user_id+'" name="inputPh'+Object.user_id+'" value="'+phone+'">'+
							'<span id="phoneNumberError" name="phoneNumberError" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<label class="control-label" for="">AlterPhone</label>'+
							'<div class="controls">'+
							'<input type="text" class="span8" id="alterphone'+Object.user_id+'" name="alterphone'+Object.user_id+'" value="'+alterphone+'">'+
							'<span id="alterphoneNumberError" name="alterphoneNumberError" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<label class="control-label" for="location">Location</label>'+
							'<div class="controls">'+
							'<input type="text" class="span8" id="location'+Object.user_id+'" name="location'+Object.user_id+'" placeholder="Please Enter location" value="'+location+'">'+
							'<span id="errorlocation" name="errorlocation" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<label class="control-label" for="inputAddress">Address</label>'+
							'<div class="controls">'+
							'<textarea rows="3" class="span8" id="txtArea'+Object.user_id+'" name="txtArea'+Object.user_id+'" placeholder="Please Enter Address">'+address+'</textarea>'+
							'<span id="addressError" name="addressError" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<label class="control-label" for="pincode">Pincode</label>'+
							'<div class="controls">'+
							'<input type="text" class="span8" id="pincode'+Object.user_id+'" name="pincode'+Object.user_id+'" placeholder="Please Enter pincode" value="'+pincode+'">'+
							'<span id="errorPincode" name="errorPincode" style="color:red"></span>'+
							'</div>'+
						'</div>'+
						'<div class="control-group">'+
						'<label class="control-label" for="city">Status</label>'+
						'<div class="controls">'+
						'<select class="span8" id="statusSelect'+Object.user_id+'" name="statusSelect'+Object.user_id+'" placeholder="">';
						if(Object.status==2){
							Editshopdetailes+='<option value="2" selected="selected">Pending</option>';
							Editshopdetailes+='<option value="1" >Active</option>';
							Editshopdetailes+='<option value="0" >Block</option>';
						}else if(Object.status==1){
							Editshopdetailes+='<option value="2" >Pending</option>';
							Editshopdetailes+='<option value="1" selected="selected">Active</option>';
							Editshopdetailes+='<option value="0" >Block</option>';
						}else{
							Editshopdetailes+='<option value="2" >Pending</option>';
							Editshopdetailes+='<option value="1" >Active</option>';
							Editshopdetailes+='<option value="0" selected="selected">Block</option>';
						}
						Editshopdetailes+='</select>'+
						'<span id="errorstate" name="errorstate" style="color:red"></span>'+
						'</div>'+
						'</div>'+
						'<div class="control-group">'+
							'<div class="controls">'+
							'<button type="button" class="medicart_btn" onclick="updateShopRequest('+Object.user_id+')">SAVE</button><span id="registerReload"></span>'+
							'</div>'+
							'<span id="sucessDiv'+Object.user_id+'" name="sucessDiv'+Object.user_id+'" style="color:green;display:none"></span>'+
						'</form>'+
						
					'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div></div>';
				html+=	'<tr>'+
							'<td>'+date_updated+'</td>'+
							'<td>'+user_name+'</td>'+
							'<td>'+email+'</td>'+
							'<td>'+phone+'</td>'+
							'<td id="status'+Object.user_id+'">'+status+'</td>'+
							'<td id="user'+Object.user_id+'">'+action+'</td>'+
						'</tr>';
		}
		pagei++;
	}		
	});
	html+='</table>';
	$('#orderHistory').html(html);
	$('#viewshop_detailes').html(viewDetailes);
	$('#view_allusers').html(viewDetailes);
	$('#Edit_shop_detailes').html(Editshopdetailes);
	return false;
}

//


function pageselectCallbackAdminNeworders(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var count=0;var html="";var phtml="";
	var auto_renewal='';
	var each_days='';
	var status='';
	var deliverdDate='';
	var action='';				
	var viewDetailes='';				
	var immidiate='';				
	var deliverdDate='';				
	var viewAll="";
	var imagees="";
	var images="";
	var value="";
	var viewallImages="";
	html+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Send Date</th>'+
				'<th>Prescription</th>'+
				'<th>Attachment</th>'+
				'<th>Status</th>'+
				'<th>Action</th>'+
			'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
	if(pagei<max_elem){
		if(Object.prescription_upload_path!=""){
		var imagess=Object.prescription_upload_path;
		images=imagess.split('**');
		if(images.length>0){
		  for(var i=0;i<1;i++){
			   if(images[i]!=null){
					imagees+='<p><img src="'+uploadImgUrl+images[i]+'" width="100px" height="100px"/></p>';
					if(images.length>1){
						imagees+='<a href="#image'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>'
					}
				}else{
					imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
				}
			}
		}
	}else{
		imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
	}
	var pdetails=Object.prescription_details;
	var details=pdetails.split('**');
	  // alert(details[0]);return false;
	if(details.length>0){
	  for(var i=0;i<=1;i++){
		   //alert(details[i]);
		   if(typeof details[i]!='undefined'){
			var names=details[i].split('$$');
			phtml+='Tabletname:'+names[0]+'<br/> Quantity:'+names[1]+'<br/>';
			}
		}
		if(details.length>2){
		  phtml+='<a href="#viewall'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>';
		}
	}
	if(Object.auto_renewal==0 || Object.auto_renewal==null){
		auto_renewal='No';
	}else{
		auto_renewal='Yes';
	}
	if(Object.each_days==0 || Object.auto_renewal==null){
		each_days='No';
	}else{
		each_days=Object.each_days;
	}
	if(Object.status==0){
		status='Pending';
		action='<p><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p><p><a id="SendQuotation'+Object.user_medicine_order_id+'" href="#"   onclick="sendQuotationPopUp('+Object.pincode+','+Object.user_medicine_order_id+');" role="button" class="" data-toggle="modal">Send Quotation</a></p><input type="hidden" id="location'+Object.user_medicine_order_id+'" value="'+Object.location+'">';
	}else if(Object.status==1){
		status='Proccessing';
		if(value=='all'){
			action='<p><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
		}else{
			action='<p><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p><p><a id="SentQuotation'+Object.user_medicine_order_id+'" href="#"   onclick="sentQuotationPopUp('+Object.user_medicine_order_id+');" role="button" class="" data-toggle="modal">Confirm Shop</a></p><input type="hidden" id="location'+Object.user_medicine_order_id+'" value="'+Object.location+'">';
		}
	}else if(Object.status==2){
		status='Processed ';
		action='<p><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
	}else if(Object.status==3){
		status='Cancelled';
		action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
	}
	if(Object.delivered_date==null){
		deliverdDate="Not delivered";
	}else{
		deliverdDate=Object.delivered_date;
	}
	if(Object.immediate==0 || Object.immediate==null){
		immidiate='Not Immidiate';
	}else{
		immidiate='Yes';
	}
	viewDetailes+='<div id="'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Order Detailes</h3></div><div id="popup" class="modal-body">'+
			'<table class="table table-condensed">'+
				'<tr><th>Tracking_id</th><th>'+Object.user_medicine_order_id+'</th></tr>'+
				'<tr><th>User name</th><th>'+Object.user_name+'</th></tr>'+
				'<tr><th>Auto Renewal </th><th>'+auto_renewal+'</th></tr>'+
				'<tr><th>Days</th><th>'+each_days+'</th></tr>'+
				'<tr><th>Delivered Date</th><th>'+deliverdDate+'</th></tr>'+
				'<tr><th>Landmark </th><th>'+Object.landmark+'</th></tr>'+
				'<tr><th>Phone number</th><th>'+Object.phone+'</th></tr>'+
				'<tr><th>Alternative Phonenumber</th><th>'+Object.alterphone+'</th></tr>'+
				'<tr><th>Address</th><th>'+Object.address+'</th></tr>'+
				'<tr><th>Immidiate</th><th>'+immidiate+'</th></tr>'+
				'<tr><th>AvailableTime</th><th>'+Object.availabletime+'</th></tr>'+
			'</table>'+	
		'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
		viewAll+='<div id="viewall'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Prescription</h3></div><div id="popup" class="modal-body">'+
			'<table class="table table-condensed">';
			viewAll+='<tr><th>Tabletname</th>'+
					'<th>Quantity</th></tr>';
			if(details.length>0){
				for(var i=0;i<=(details.length-1);i++){
					var names=details[i].split('$$');
					viewAll+='<tr><th>'+names[0]+'</th>'+
					'<th>'+names[1]+'</th></tr>';
				}
			}
			viewAll+='</table>'+	
		'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
		viewallImages+='<div id="image'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Images</h3></div><div id="popup" class="modal-body">';
		viewallImages+='<div id="myCarousel'+Object.user_medicine_order_id+'" class="carousel slide">'+
		'<ol class="carousel-indicators">';
		if(images.length>0){
			for(var img=0;img<=(images.length)-1;img++){
				//if(img==0){
					viewallImages+='<li data-target="#myCarousel'+Object.user_medicine_order_id+'" data-slide-to="'+img+'" class="active"></li>';
				//}
			}
		}
		viewallImages+='</ol>'+
		'<!-- Carousel items -->'+
		'<div class="carousel-inner">';
		if(images.length>0){
			for(var img=0;img<=(images.length)-1;img++){
				if(img==0){
					viewallImages+='<div class="active item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
				}else{
					viewallImages+='<div class="item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
				}
				
			}
		}
		viewallImages+='</div>'+
		'<!-- Carousel nav -->'+
		'<a class="carousel-control left" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="prev">&lsaquo;</a>'+
		'<a class="carousel-control right" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="next">&rsaquo;</a>'+
		'</div>';
		viewallImages+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
		html+=	'<tr>'+
				'<td>'+Object.date_added+'</td>'+
				'<td>'+phtml+'</td>'+
				'<td>'+imagees+'</td>'+
				'<td id="status'+Object.user_medicine_order_id+'">'+status+'</td>'+
				'<td id="action'+Object.user_medicine_order_id+'">'+action+'</td>'+
			'</tr>';
	phtml="";
	imagees="";
}
pagei++;
}
});
html+='</table>';
$('#orderHistory').html(html);
$('#viewDetailes_id').html(viewDetailes);				
$('#viewall_detailes').html(viewAll);				
$('#viewall_Imags').html(viewallImages);
var status = getParameterByName('status');
if(status=='cancelled'){
	$('#success_alert').show();
	$("#cancelled_order").html("Cancelled order successfully");
	$("html, body").animate({ scrollTop: 0 }, 600);
	$('#success_alert').delay(3000).fadeOut('slow');
}
	return false;
}
//
function pageselectCallbackAdminRenewalorder(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var html="";
	var phtml="";
	var auto_renewal='';
	var each_days='';
	var status='';
	var delivered_date='';
	var action='';
	var viewAll='';
	var imagees="";
	var images="";
	var view_renewal_detailes='';
	var viewallImages='';
	html+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Send Date</th>'+
				'<th>Prescription</th>'+
				'<th>Attachment</th>'+
				'<th>Status</th>'+
				'<th>Action</th>'+
			'</tr>';;
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
		if(pagei<max_elem){
			if(Object.prescription_upload_path!=""){
				var imagess=Object.prescription_upload_path;
				images=imagess.split('**');
				if(images.length>0){
				  for(var i=0;i<1;i++){
					   if(images[i]!=null){
							imagees+='<p><img src="'+uploadImgUrl+images[i]+'" width="100px" height="100px"/></p>';
							if(images.length>1){
								imagees+='<a href="#Renewal_image'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>'
							}
						}else{
							imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
						}
					}
				}else{
					imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
				}
			}else{
				imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
			}
			var pdetails=Object.prescription_details;
			var details=pdetails.split('**');
			if(details.length>0){
				  for(var i=0;i<=1;i++){
					   if(typeof details[i]!='undefined'){
						var names=details[i].split('$$');
						phtml+='Tabletname:'+names[0]+'<br/> Quantity:'+names[1]+'<br/>';
						}
					}
					if(details.length>2){
					  phtml+='<a href="#viewall'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>';
					}
				}
			if(Object.auto_renewal==0 || Object.auto_renewal==null){
				auto_renewal='No';
			}else{
				auto_renewal='Yes';
			}
			if(Object.each_days==0 || Object.auto_renewal==null){
				each_days='No';
			}else{
				each_days=Object.each_days;
			}
			if(Object.status==0){
				status='<p>Pending</p>';
				action='<p id="cancelautorenewal'+Object.user_medicine_order_id+'"><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="javascript:void(0)" onclick="cancelautorenewalFun('+Object.user_medicine_order_id+',0)">Cancel autorenewal</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
			}else if(Object.status==2){
				status='<p>Processed</p>';
				action='<p id="cancelautorenewal'+Object.user_medicine_order_id+'"><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="javascript:void(0)" onclick="cancelautorenewalFun('+Object.user_medicine_order_id+',0)">Cancel autorenewal</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
			}else if(Object.status==3){
				status='<p>Cancelled</p>';
				action='<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}else{
				status='<p>Processing</p>';
				action='<a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a>';
			}
			if(Object.delivered_date=="" || Object.delivered_date==null){
				delivered_date="Not delivered";
			}else{
				delivered_date=Object.delivered_date;
			}
			if(Object.immediate==0 || Object.immediate==null){
					immidiate='Not Immidiate';
			}else{
					immidiate='Yes';
			}
			if(Object.delivered_date==null){
					var deliverdDate="Not Delivered ";
			}else{
					deliverdDate=Object.delivered_date;
			}
				view_renewal_detailes+='<div id="'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Renewal Order Detailes</h3></div><div id="popup" class="modal-body">'+
						'<table class="table table-condensed">'+
							'<tr><th>Tracking_id</th><th>'+Object.user_medicine_order_id+'</th></tr>'+
							'<tr><th>User name</th><th>'+Object.user_name+'</th></tr>'+
							'<tr><th>Auto Renewal </th><th id="auto'+Object.user_medicine_order_id+'">'+auto_renewal+'</th></tr>'+
							'<tr><th>Days</th><th>'+each_days+'</th></tr>'+
							'<tr><th>Delivered Date</th><th>'+deliverdDate+'</th></tr>'+
							'<tr><th>Landmark </th><th>'+Object.landmark+'</th></tr>'+
							'<tr><th>Phone </th><th>'+Object.phone+'</th></tr>'+
							'<tr><th>Alternative Phonenumber</th><th>'+Object.alterphone+'</th></tr>'+
							'<tr><th>Address</th><th>'+Object.address+'</th></tr>'+
							'<tr><th>Immidiate</th><th>'+immidiate+'</th></tr>'+
							'<tr><th>AvailableTime</th><th>'+Object.availabletime+'</th></tr>'+
						'</table>'+	
					'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
				viewAll+='<div id="viewall'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Prescription</h3></div><div id="popup" class="modal-body">'+
						'<table class="table table-condensed">';
						viewAll+='<tr><th>Tabletname</th>'+
								'<th>Quantity</th></tr>';
						if(details.length>0){
							for(var i=0;i<=(details.length-1);i++){
								var names=details[i].split('$$');
								viewAll+='<tr><th>'+names[0]+'</th>'+
								'<th>'+names[1]+'</th></tr>';
							}
						}
						viewAll+='</table>'+	
					'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
				viewallImages+='<div id="Renewal_image'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Images</h3></div><div id="popup" class="modal-body">';
					viewallImages+='<div id="myCarousel'+Object.user_medicine_order_id+'" class="carousel slide">'+
					'<ol class="carousel-indicators">';
					if(images.length>0){
						for(var img=0;img<=(images.length)-1;img++){
							//if(img==0){
								viewallImages+='<li data-target="#myCarousel'+Object.user_medicine_order_id+'" data-slide-to="'+img+'" class="active"></li>';
							//}
						}
					}
					viewallImages+='</ol>'+
					'<!-- Carousel items -->'+
					'<div class="carousel-inner">';
					if(images.length>0){
						for(var img=0;img<=(images.length)-1;img++){
							if(img==0){
								viewallImages+='<div class="active item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
							}else{
								viewallImages+='<div class="item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
							}
							
						}
					}
					viewallImages+='</div>'+
					'<!-- Carousel nav -->'+
					'<a class="carousel-control left" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="prev">&lsaquo;</a>'+
					'<a class="carousel-control right" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="next">&rsaquo;</a>'+
					'</div>';
					viewallImages+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
				html+=	'<tr>'+
						'<td>'+Object.date_added+'</td>'+
						'<td>'+phtml+'</td>'+
						'<td>'+imagees+'</td>'+							
						'<td id="status'+Object.user_medicine_order_id+'">'+status+'</td>'+
						'<td id="action'+Object.user_medicine_order_id+'">'+action+'</td>'+
					'</tr>';
			phtml="";
			imagees="";
		}
			pagei++;
		}
	});
		html+='</table>';
		$('#renuwalorder_detailes').html(html);
		$('#viewrenewalDetailes_id').html(view_renewal_detailes);
		$('#viewallrenewal').html(viewAll);
		$('#viewallrenewal_Images').html(viewallImages);
		var status = getParameterByName('status');
		if(status=='cancelled'){
			$('#success_alert').show();
			$("#cancelled_autorenewalorder").html(Renewal_canclled_message);
			$("html, body").animate({ scrollTop: 0 }, 600);
			$('#success_alert').delay(3000).fadeOut('slow');
		}

}
//
function AdminTommorrowRenewalorder(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var html="";
	var phtml="";
	var auto_renewal='';
	var each_days='';
	var status='';
	var delivered_date='';
	var action='';
	var viewAll='';
	var imagees="";
	var images="";
	var view_renewal_detailes='';
	var viewallImages='';
	html+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Send Date</th>'+
				'<th>Prescription</th>'+
				'<th>Attachment</th>'+
				'<th>Action</th>'+
			'</tr>';
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
	if(pagei<max_elem){		
		if(Object.prescription_upload_path!=""){
		var imagess=Object.prescription_upload_path;
		images=imagess.split('**');
		if(images.length>0){
		  for(var i=0;i<1;i++){
			   if(images[i]!=null){
					imagees+='<p><img src="'+uploadImgUrl+images[i]+'" width="100px" height="100px"/></p>';
					if(images.length>1){
						imagees+='<a href="#Renewal_image'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>'
					}
				}else{
					imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
				}
			}
		}else{
			imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
		}
	}else{
		imagees+='<p><img src="'+uploadImgUrl+'default.jpg" width="100px" height="100px"/></p>';
	}
	var pdetails=Object.prescription_details;
	var details=pdetails.split('**');
	if(details.length>0){
		  for(var i=0;i<=1;i++){
			   if(typeof details[i]!='undefined'){
				var names=details[i].split('$$');
				phtml+='Tabletname:'+names[0]+'<br/> Quantity:'+names[1]+'<br/>';
				}
			}
			if(details.length>2){
			  phtml+='<a href="#viewall'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">ViewAll</a>';
			}
		}
	if(Object.auto_renewal==0 || Object.auto_renewal==null){
		auto_renewal='No';
	}else{
		auto_renewal='Yes';
	}
	if(Object.each_days==0 || Object.auto_renewal==null){
		each_days='No';
	}else{
		each_days=Object.each_days;
	}
	if(Object.status==2){
		action+='<p><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
		if(Object.auto_renewal==2){
		action+='<p>Send Success</p>';
		}else{
		action+='<p id="sendorderre'+Object.user_medicine_order_id+'"><a href="javascript:void(0)" onclick="sendOrderToNewOrders('+Object.user_id+','+Object.user_medicine_order_id+')">Send order to New orders</a></p>';
		}
	}else if(Object.status==3){
		action+='<p><a href="javascript:void(0)" onclick="cancelOrder('+Object.user_medicine_order_id+')">Cancel</a>'+'/'+'<a href="#'+Object.user_medicine_order_id+'" role="button" class="" data-toggle="modal">View</a></p>';
		if(Object.auto_renewal==2){
		action+='<p>Send Success</p>';
		}
	}
	if(Object.delivered_date=="" || Object.delivered_date==null){
		delivered_date="Not delivered";
	}else{
		delivered_date=Object.delivered_date;
	}
	if(Object.immediate==0 || Object.immediate==null){
			immidiate='Not Immidiate';
	}else{
			immidiate='Yes';
	}
	if(Object.delivered_date==null){
			var deliverdDate="Not Delivered ";
	}else{
			deliverdDate=Object.delivered_date;
	}
		view_renewal_detailes+='<div id="'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Renewal Order Detailes</h3></div><div id="popup" class="modal-body">'+
				'<table class="table table-condensed">'+
					'<tr><th>Tracking_id</th><th>'+Object.user_medicine_order_id+'</th></tr>'+
					'<tr><th>User name</th><th>'+Object.user_name+'</th></tr>'+
					'<tr><th>Auto Renewal </th><th id="auto'+Object.user_medicine_order_id+'">'+auto_renewal+'</th></tr>'+
					'<tr><th>Days</th><th>'+each_days+'</th></tr>'+
					'<tr><th>Delivered Date</th><th>'+deliverdDate+'</th></tr>'+
					'<tr><th>Landmark </th><th>'+Object.landmark+'</th></tr>'+
					'<tr><th>Phone </th><th>'+Object.phone+'</th></tr>'+
					'<tr><th>Alternative Phonenumber</th><th>'+Object.alterphone+'</th></tr>'+
					'<tr><th>Address</th><th>'+Object.address+'</th></tr>'+
					'<tr><th>Immidiate</th><th>'+immidiate+'</th></tr>'+
					'<tr><th>AvailableTime</th><th>'+Object.availabletime+'</th></tr>'+
				'</table>'+	
			'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
		viewAll+='<div id="viewall'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Prescription</h3></div><div id="popup" class="modal-body">'+
				'<table class="table table-condensed">';
				viewAll+='<tr><th>Tabletname</th>'+
						'<th>Quantity</th></tr>';
				if(details.length>0){
					for(var i=0;i<=(details.length-1);i++){
						var names=details[i].split('$$');
						viewAll+='<tr><th>'+names[0]+'</th>'+
						'<th>'+names[1]+'</th></tr>';
					}
				}
				viewAll+='</table>'+	
			'</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
		viewallImages+='<div id="Renewal_image'+Object.user_medicine_order_id+'" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-header"><h3 id="myModalLabel">Images</h3></div><div id="popup" class="modal-body">';
			viewallImages+='<div id="myCarousel'+Object.user_medicine_order_id+'" class="carousel slide">'+
			'<ol class="carousel-indicators">';
			if(images.length>0){
				for(var img=0;img<=(images.length)-1;img++){
					//if(img==0){
						viewallImages+='<li data-target="#myCarousel'+Object.user_medicine_order_id+'" data-slide-to="'+img+'" class="active"></li>';
					//}
				}
			}
			viewallImages+='</ol>'+
			'<!-- Carousel items -->'+
			'<div class="carousel-inner">';
			if(images.length>0){
				for(var img=0;img<=(images.length)-1;img++){
					if(img==0){
						viewallImages+='<div class="active item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
					}else{
						viewallImages+='<div class="item"><img width="500px;" height="500px;" src="'+uploadImgUrl+images[img]+'"></div>';
					}
					
				}
			}
			viewallImages+='</div>'+
			'<!-- Carousel nav -->'+
			'<a class="carousel-control left" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="prev">&lsaquo;</a>'+
			'<a class="carousel-control right" href="#myCarousel'+Object.user_medicine_order_id+'" data-slide="next">&rsaquo;</a>'+
			'</div>';
			viewallImages+='</div><div class="modal-footer"><button class="btn" data-dismiss="modal" ria-hidden="true">Close</button></div></div>';
		html+=	'<tr>'+
				'<td>'+Object.date_added+'</td>'+
				'<td>'+phtml+'</td>'+
				'<td>'+imagees+'</td>'+							
				'<td id="action'+Object.user_medicine_order_id+'">'+action+'</td>'+
			'</tr>';
	phtml="";
	imagees="";
	action="";
	}
	pagei++;
	}	
	});
	html+='</table>';
	$('#renuwalorder_detailes').html(html);
	$('#viewrenewalDetailes_id').html(view_renewal_detailes);
	$('#viewallrenewal').html(viewAll);
	$('#viewallrenewal_Images').html(viewallImages);
	var status = getParameterByName('status');
	if(status=='cancelled'){
		$('#success_alert').show();
		$("#cancelled_autorenewalorder").html("Cancelled auto renewal successfully");
		$("html, body").animate({ scrollTop: 0 }, 600);
		$('#success_alert').delay(3000).fadeOut('slow');
	}
		return false;
}
	

function pageselectCallbackAdmindiscounts(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var count=0;
	var dhtml="";
	var address="";
	var prescription="";
	dhtml+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Post Order Date</th>'+
				'<th>Delivered Date</th>'+
				'<th>Tracking ID</th>'+
				'<th>Shop Name</th>'+
				'<th>Status</th>'+
				'<th>Discount</th>'+
				'<th>Action</th>'+
			'</tr>';
	var obj = eval(members);	
	$.each(obj, function (index,Object){
	if(pagei==index){
	if(pagei<max_elem){
	address+='<p>'+Object.shop_name+'</p>'+'<p>'+Object.address+'</p>'+'<p>Location:'+Object.location+'</p>'+
	'<p>Pincode:'+Object.pincode+'</p>'+'<p>Contact:'+Object.phone+'</p>';
	var pdetails=Object.prescription_details;
	var details=pdetails.split('**');
	for(var i=0;i<=(details.length-1);i++){
		var names=details[i].split('$$');
		prescription+='<p>Tablet Name:'+names[0]+'&nbsp;&nbsp;&nbsp;Quantity:'+names[1]+'</p>';
	}
	if(Object.admin_paid_status==0){
		var status='Not Paid';
		var action='<a href="javascript:void(0);" onclick="paidDiscount('+Object.user_medicine_order_id+')">Paid</a>';
	}else{
		var status='Paid';
		var action='Completed';
	}
	dhtml+=	'<tr>'+
			'<td>'+Object.added_date+'</td>'+
			'<td>'+Object.delivered_date+'</td>'+
			'<td>'+Object.user_medicine_order_id+'</td>'+
			'<td>'+address+'</td>'+
			'<td id="status'+Object.user_medicine_order_id+'">'+status+'</td>'+
			'<td>Rs '+Object.discount+'.00</td>'+
			'<td id="action'+Object.user_medicine_order_id+'">'+action+'</td>'+
		'</tr>';
	address="";
	prescription="";
	status="";
	action="";
	}
		pagei++;
	}
	});
	dhtml+='</table>';
	$('.container_form_top').html(dhtml);
	return false;
}

//

function pageselectCallbackAdmincomplints(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var chtml='';
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
	if(pagei<max_elem){
		
		chtml+='<div class="media">'+
				'<a class="pull-left" href="#">'+
					'<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile">'+
				'</a>'+
				'<div class="media-body">'+
					'<h4 id="shop_name_complaint" class="media-heading">'+Object.user_name+'&nbsp;&nbsp;&nbsp;&nbsp;'+'TRACKING ID:'+Object.complaint_on_id+'</h4>'+
					'<p id="shop_name_complaint_text">'+Object.complaint+'</p>';
		
		if(Object.reply_text!=null){
			chtml+='<div class="media">'+
				'<a class="pull-left" href="#">'+
				'<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile">'+
				'</a>'+
				'<div class="media-body">'+
					'<h4 class="media-heading">Replay&nbsp;&nbsp;&nbsp;'+Object.shop_name+'</h4>'+
					'<p>'+Object.reply_text+'</p>';
				chtml+='</div>'+
			'</div>';
		}
		
	}
	chtml+='</div>'+'</div>';
	pagei++;
	}
	});
	$("#complaint_replies").html(chtml);
	return false;
}

function pageselectCallbackAdminreviews(page_index, jq){
	var items_per_page = $('#items_per_page').val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var pagei=page_index*items_per_page;
	var html="";
	var rhtml="";
	var obj = eval(members);
	$.each(obj, function (index,Object){
	if(pagei==index){
	if(pagei<max_elem){
		
		html+='<div class="media">';
		html+='<a class="pull-left" href="#">';
		html+='<img src="https://lh3.googleusercontent.com/uFp_tsTJboUY7kue5XAsGA=w48-c-h48" class="media-object img_profile"></a>';		  
		html+='<div class="media-body">';
		var value=Object.rating;
		for(var i=1;i<=value;i++){
			rhtml+='<img class="star" src="images/green-star.png">';
		}for(var j=i;j<=5;j++){
			rhtml+='<img class="star" src="images/gray-star.png">';
		}
		html+='<h4>'+rhtml+'</h4>';
		if(Object.shop_name!=null){
		html+='<h4 class="media-heading">'+Object.user_name+' To '+Object.shop_name+ ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tracking ID: '+Object.tracking_id+'</h4>';
		}else{
		html+='<h4 class="media-heading">'+Object.user_name+' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tracking ID: '+Object.tracking_id+'</h4>';
		}
		html+= Object.review;	 
		html+='</div>'; 
		html+='</div>';
		rhtml="";
	}
	pagei++;
	}
	});
	$("#all_review_list").html(html);
	return false;
}

//Admin Notifications
function adminNotification(type){
	var admin_id = JSON.parse(sessionStorage["admin_user_id"]);
	$.ajax({
		type		:	'GET',
		url			:  	webServiceUrl+'notifications/'+type+'-'+admin_id,
		dataType	: 	"json",
		success: function(data){
		$('#forgetReload').html('');
			if(data.value==1){
				var notifications="";
				var notification_type="";
				var action="";
				notifications+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Date</th>'+
				'<th>Notification</th>'+
				'<th>Type</th>'+
				'<th>Action</th>'+
				'</tr>';
				var obj = eval("(" + data.notifications + ")");
				$.each(obj, function (index,Object){
					if(Object.type=="RENEWAL ORDER"){
						notification_type=Object.user_name+' Post New '+Object.type;
						action='<a href="javascript:void(0)" onclick="viewreneorderNotifications('+Object.order_id+',3,'+Object.user_type_id+')">VIEW</a>';
						
					}else if(Object.type=="ORDER"){
						notification_type=Object.user_name+' Post New '+Object.type;
						action='<a href="javascript:void(0)" onclick="vieworderNotifications('+Object.order_id+',4,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Complaint"){
						if(Object.notifiedby=="USER"){
							notification_type=Object.user_name + Object.type +' By An Order Tracking Id ' + Object.order_id ;
							action='<a href="javascript:void(0)" onclick="viewComplaintNotifications('+Object.notifications_id+',5,'+Object.user_type_id+')">VIEW</a>';
						}else{
							notification_type='Shop Replay By ' + Object.type +'On Order Tracking Id ' + Object.order_id ;
							action='<a href="javascript:void(0)" onclick="viewShopNotifications('+Object.notifications_id+',5,'+Object.user_type_id+')">VIEW</a>';
						}
					}else if(Object.type=="ReviewRating"){
						notification_type=Object.user_name+' Post A ' + Object.type +' By An Order Tracking Id ' + Object.order_id ;
						action='<a href="javascript:void(0)" onclick="viewReviewNotifications('+Object.notifications_id+',6,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Register"){
						notification_type=' New User '+ Object.type;
						action='<a href="javascript:void(0)" onclick="viewUregNotifications('+Object.user_id+',7,'+Object.user_type_id+')">VIEW</a>';
					}
					else if(Object.type=="Shopregister"){
						notification_type='New '+ Object.type;
						action='<a href="javascript:void(0)" onclick="viewShopregNotifications('+Object.user_id+',8,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="sendPrice"){
						notification_type='Shop  '+ Object.type +' To An Order Tracking Id ' + Object.order_id ;
						action='<a href="javascript:void(0)" onclick="viewSendPriceNotifications('+Object.notifications_id+',11,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="OrderConfirmed"){
						notification_type='Shop  Deliverd To An Order Tracking Id ' + Object.order_id ;
						action='<a href="javascript:void(0)" onclick="viewOrderConfirmedNotifications('+Object.notifications_id+',16,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Cancelled Auto Renewal"){
						notification_type= Object.user_name + Object.type +' By  Renewal Order';
						action='<a href="javascript:void(0)" onclick="viewrenewalConfirmedNotifications('+Object.order_id+',13,'+Object.user_type_id+')">VIEW</a>';
					}else if(Object.type=="Enabled Auto Renewal"){
						notification_type= Object.user_name + Object.type +' By  Renewal Order';
						action='<a href="javascript:void(0)" onclick="viewrenewalConfirmedNotifications('+Object.order_id+',14,'+Object.user_type_id+')">VIEW</a>';
					}
					notifications+=	'<tr>'+
						'<td>'+Object.added_date+'</td>'+
						'<td>'+notification_type+'</td>'+
						'<td>'+Object.type+'</td>'+
						'<td>'+action+'</td>'+
					'</tr>';
				});
				$('#notifications').html(notifications);
				$('#count').html("");
			}else{
				$('#notifications').html("Notifications Empty");
			}
		}
	});
}

function viewreneorderNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,1,ordertype,usertype,0);
}
function vieworderNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,2,ordertype,usertype,0);
}
function viewComplaintNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,3,ordertype,usertype,3);
}
function viewReviewNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,4,ordertype,usertype,3);
}
function viewShopNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,3,ordertype,usertype,3);
}
function viewUregNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,5,ordertype,usertype,1);
}
function viewShopregNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,6,ordertype,usertype,1);
}
function viewSendPriceNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,7,ordertype,usertype,3);
}
function viewOrderConfirmedNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,8,ordertype,usertype,3);
}
function viewrenewalConfirmedNotifications(orderId,ordertype,usertype){
	changeNotificationStatus(orderId,9,ordertype,usertype,0);
}
function changeNotificationStatus(OrderId,type,ordertype,usertype,updatetype){
	$.ajax({
		type		:	'PUT',
		url			:  	webServiceUrl+'notifications/'+OrderId,
		dataType	: 	"json",
		data		:	{
							OrderType:ordertype,userType:usertype,updatetype:updatetype
						},
		success: function(data){
			if(data.value==1){
				if(type==1){
					window.location="renewal-orders.html";
				}else if(type==2){
					window.location="new-orders.html";
				}else if(type==3){
					window.location="complaints.html";
				}else if(type==4){
					window.location="reviews.html";
				}else if(type==5){
					window.location="all-users.html";
				}else if(type==6){
					window.location="all-shops.html";
				}else if(type==7){
					window.location="quotation-sent-orders.html";
				}else if(type==8){
					window.location="order-history.html";
				}else if(type==9){
					window.location="new-orders.html";
				}
			}
		}
	});	
}
//Get Notification history
function getAdminNotifications(type){
var admin_id = JSON.parse(sessionStorage["admin_user_id"]);
	$.ajax({
		type		:	'POST',
		url			:  	webServiceUrl+'notifications',
		dataType	: 	"json",
		data		:	{usertype:type,user_id:admin_id},
		success: function(data){
			if(data.value==1){
				var adminnotifications="";
				var adminnotification_type="";
				adminnotifications+='<table class="table table-bordered">'+
				'<tr class="table_th_bg">'+
				'<th>Date</th>'+
				'<th>Notification</th>'+
				'<th>Type</th>'+
				'</tr>';
				var obj = eval("(" + data.noitifications + ")");
				var deletIds="";
				$.each(obj, function (index,Object){
					if(Object.type=="RENEWAL ORDER"){
						adminnotification_type=' User Post New '+Object.type;
					}else if(Object.type=="ORDER"){
						adminnotification_type='User  Post New '+Object.type;
					}else if(Object.type=="Complaint"){
						if(Object.notifiedby=="USER"){
							adminnotification_type='User '+ Object.type +' By An Order Tracking Id ' + Object.order_id ;
						}else{
							adminnotification_type='Shop Replay By ' + Object.type +'On Order Tracking Id ' + Object.order_id ;
						}
					}else if(Object.type=="ReviewRating"){
						adminnotification_type='User Post A ' + Object.type +' By An Order Tracking Id ' + Object.order_id ;
					}else if(Object.type=="Register"){
						adminnotification_type=' New User '+ Object.type;
					}
					else if(Object.type=="Shopregister"){
						adminnotification_type='New '+ Object.type;
					}else if(Object.type=="sendPrice"){
						adminnotification_type='Shop  '+ Object.type +' To An Order Tracking Id ' + Object.order_id ;
					}else if(Object.type=="OrderConfirmed"){
						adminnotification_type='Shop  Deliverd To An Order Tracking Id ' + Object.order_id ;
					}else if(Object.type=="Cancelled Auto Renewal"){
						adminnotification_type= 'User ' + Object.type +' By  Renewal Order';
					}else if(Object.type=="Enabled Auto Renewal"){
						adminnotification_type= 'User '+ Object.type +' By  Renewal Order';
					}
					adminnotifications+='<tr>'+
						'<td>'+Object.added_date+'</td>'+
						'<td>'+adminnotification_type+'</td>'+
						'<td>'+Object.type+'</td>'+
					'</tr>';
				});
				$('#notifications').html(adminnotifications);
			}else{
				$('#notifications').html("History Is Empty");
			}
		}
	});	
}